﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Silvery;
using Silvery.Scene;
using System.Windows.Resources;
using System.IO;
using System.Windows.Markup;
using Silvery.Role.Standard;

namespace Sample03_Scene
{
    public class Sample_3 : GameRoot
    {
        NScene scene = new NScene();
        StandardRole hero;
        public Sample_3()
            :base(App.Current.RootVisual as FrameworkElement)
        {

            this.AddBaseObj(scene);
            scene.SceneEnter(LoadXAMLAndGetShape(new Uri("/Sample03_Scene;component/Scene01.xaml", UriKind.Relative)));
            //scene.SceneEnter(new Scene02());
            hero = new StandardRole(new Uri("download/Sample_Role/PC001.zip", UriKind.Relative));
            scene.Hero = hero;
            hero.Position = new Point(1600, 600);
        }
        FrameworkElement LoadXAMLAndGetShape(Uri url)
        {
            string xaml = string.Empty;
            StreamResourceInfo sri = Application.GetResourceStream(url);
            using (StreamReader sr = new StreamReader(sri.Stream))
            {
                xaml = sr.ReadToEnd();
            }
            return (FrameworkElement)XamlReader.Load(xaml);
        }

    }
}
